<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/22
 * Time: 16:10
 */

class Shopify_down_model extends CI_Model
{
    public $type;

    public function __construct($param = array())
    {
        parent::__construct();
        $this->type = intval($param['type']);
    }

    public function shopify_down_time($web_id)
    {
        $this->db->from('shopify_down');
        $this->db->where('type', $this->type);
        $this->db->where('web_id',$web_id);
        $this->db->order_by('down_time DESC');

        $query = $this->db->get();
        $shopify_down = $query->row_array();
        return $shopify_down['down_time'];
    }

    public function insert_shopify_down($data = array())
    {
        if ($data) {
            $data['type'] = $this->type;
            $this->db->insert('shopify_down', $data);

            return true;
        }

        return false;
    }
}